﻿<!doctype html>
<html>
<head>
    <meta charset="utf-8" />
    <title>NKeditor 在线编辑器 PHP demo</title>

    <script charset="utf-8" src="NKeditor-all.js"></script>
    <!-- 下面是外部插件不是必须引入的 -->
    <script charset="utf-8" src="libs/jquery.min.js"></script>
    <script charset="utf-8" src="libs/JDialog/JDialog.min.js"></script>
    <script type="text/javascript" src="WordPaster/js/json2.min.js" charset="utf-8"></script>
    <script type="text/javascript" src="WordPaster/js/layer-3.1.1/layer.js" charset="utf-8"></script>
    <script type="text/javascript" src="WordPaster/js/w.layer.js" charset="utf-8"></script>
    <script type="text/javascript" src="zyCapture/z.layer.js" charset="utf-8"></script>
    <script type="text/javascript" src="zyOffice/js/o.layer.js" charset="utf-8"></script>
    <script>
        var pos = window.location.href.lastIndexOf("/");
		var api = [
			window.location.href.substr(0, pos + 1),
			"asp.net/upload.aspx"
		].join("");
		WordPaster.getInstance({
			//上传接口：http://www.ncmem.com/doc/view.aspx?id=d88b60a2b0204af1ba62fa66288203ed
			PostUrl: api,
			//为图片地址增加域名：http://www.ncmem.com/doc/view.aspx?id=704cd302ebd346b486adf39cf4553936
			ImageUrl: "",
			//设置文件字段名称：http://www.ncmem.com/doc/view.aspx?id=c3ad06c2ae31454cb418ceb2b8da7c45
			FileFieldName: "file",
			//提取图片地址：http://www.ncmem.com/doc/view.aspx?id=07e3f323d22d4571ad213441ab8530d1
            ImageMatch: '',
            event:{
				dataReady:function(e){
					//e.word,
					//e.imgs:tag1,tag2,tag3
					console.log(e.imgs)
				}
			}
		});//加载控件

        //zyCapture
        zyCapture.getInstance({
            config: {
                PostUrl: api,
				FileFieldName: "file",
                Fields: { uname: "test" }
            }
        });

		//zyoffice
		//使用前请在服务端部署zyOffice，
		//http://www.ncmem.com/doc/view.aspx?id=82170058de824b5c86e2e666e5be319c
		zyOffice.getInstance({
			word:"http://localhost:13710/zyoffice/word/convert",
			wordExport:"http://localhost:13710/zyoffice/word/export",
			pdf:"http://localhost:13710/zyoffice/pdf/upload"
		});

        KindEditor.ready(function (K) {
            K.create('textarea[name="content1"]', {
                uploadJson: K.basePath + 'php/qiniu/upload_json.php',
                fileManagerJson: K.basePath + 'php/qiniu/file_manager_json.php',
                dialogOffset: 0, //对话框距离页面顶部的位置，默认为0居中，
                allowFileManager: true,
                allowImageUpload: true,
                allowMediaUpload: true,
                afterCreate: function () {
                    var self = this;
                    K.ctrl(document, 13, function () {
                        self.sync();
                        K('form[name=example]')[0].submit();
                    });
                    K.ctrl(self.edit.doc, 13, function () {
                        self.sync();
                        K('form[name=example]')[0].submit();
                    });
                    WordPaster.getInstance().SetEditor(this);
					var self = this;
					//自定义 Ctrl + V 事件。
					KindEditor.ctrl(self.edit.doc, 'V', function () { WordPaster.getInstance().Paste(); });
                },
                themeType: "default", //主题
                //错误处理 handler
                errorMsgHandler: function (message, type) {
                    try {
                        JDialog.msg({ type: type, content: message, timer: 2000 });
                    } catch (Error) {
                        alert(message);
                    }
                }
            });

        });
    </script>
</head>
<body>
<form name="example" method="post" style="margin-top: 20px;">
	<textarea name="content1" style="width:900px;height:500px;visibility:hidden;"></textarea>
</form>
</body>
</html>

